package com.huawang.mdesign.model.service.constant;

import lombok.Getter;

import java.util.Arrays;

/**
 * 模型属性合并单一属性处理规则
 */
@Getter
public enum OwnedPropertyMergeRuleEnum {
    TYPE_AND_PROPERTY_NAME_MATCH_PROPERTY_MERGE(1, "类型和名称相同的属性合并"),
    TYPE_AND_PROPERTY_NAME_MATCH_PROPERTY_DO_NOT_MERGE(2, "类型和名称相同的属性不合并");
    private final int code;
    private final String desc;

    OwnedPropertyMergeRuleEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static boolean isOwnedPropertyMergeRule(Integer code) {
        return code != null && Arrays.stream(values()).anyMatch(e -> e.getCode() == code);
    }

}
